/*
 * KIMWONSORK@GMAIL.COM
 * COPYRIGHT CRAYONSOFT All rights reserved.
 * 2013오후 8:51:08
 * kws
 */

package com.crayon.account.item.adapter;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

import com.crayon.account.dao.DAOAccount;
import com.crayon.sharemenu.R;
import com.crayon.util.GDB;
import com.crayon.util.UIBIND;
import com.crayon.util.UTILCurrency;
import com.crayon.util.UTILDate;

public class AdapterDaoAccountSingle extends ArrayAdapter<DAOAccount> {

	String query;
	private LayoutInflater mInflater = null;
	public AdapterDaoAccountSingle(Context context) {
		super(context,android.R.layout.simple_list_item_activated_1);
		// TODO Auto-generated constructor stub
		mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
//		convertView = convertView==null ? mInflater.inflate(android.R.layout.simple_expandable_list_item_2, null, false):convertView;
		convertView = convertView==null ? mInflater.inflate(android.R.layout.simple_list_item_activated_2, null, false):convertView;
		DAOAccount item = getItem(position);
		
		GDB.log(getClass(), "query " + getQuery());
		UIBIND.bindTextQueryColor(convertView, android.R.id.text1, 
				String.format("%s\t\t%s"
						, item.getSummary()
						, item.getDesciption()!=null ?item.getDesciption():getContext().getString(R.string.dao_no_datas)
						)
				,getQuery()
				);
		
		UIBIND.bindText(convertView, android.R.id.text2, 
				String.format("%s\t[%s]\t%s",
						UTILDate.getYYYYMMDDwithPeriod(item.getDtStart())
						, item.getxCategory()!=null ? item.getxCategory():getContext().getString(R.string.dao_key_nocate)
								,UTILCurrency.formatCurrencyPrice(item.getXprice())
								)
				);
		if(convertView instanceof ViewGroup){
			ViewGroup layout = (ViewGroup)convertView;
			for(int i=0;i < layout.getChildCount();i++){
				GDB.log(getClass(),"child" + layout.getChildAt(i) +" \tid" + layout.getChildAt(i).getId());
			}
		}
		UIBIND.bindImageView(convertView, android.R.id.icon,R.drawable.ic_feel_0);
		
		return convertView;
	}
	public String getQuery() {
		return query;
	}
	public void setQuery(String query) {
		this.query = query;
	}
	
	



}
